package servlety;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import klient.Klient;
import baza.*;
/**
 * Servlet implementation class InformacjeKlienta
 */
@WebServlet("/InformacjeKlienta")
public class InformacjeKlienta extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public InformacjeKlienta() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	protected Vector pobierzKlientow(){
		BazaDanych a = new BazaDanych();
		return a.stworzListe("klient");
	}
	
	protected String createDropDownList(){
		Vector<Klient> klienci = pobierzKlientow();
		String list = "";
		list+="<html><body><select name=\"klientList\">";
		for (Klient klient : klienci) {
			list+="<option value=\"" + klient.getId() + "\">" + klient.getImie() + " " + klient.getNazwisko() + "</option>";
		}
		list+="</select></body></html>";
		return list;
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter out = response.getWriter();
		
		out.print(createDropDownList());
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}